/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sv.com.dizucar.controlador;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author 43579648
 */
public class Conexion {

    public Conexion() {
    }
    
    
    private static EntityManager entityManager;

    public static EntityManager getEntityManager() {
        if(entityManager==null){
            cargarConexion(); 
        }
        return entityManager;
    }

    public static void cargarConexion(){
        EntityManagerFactory emf = Persistence.createEntityManagerFactory("WebDizucarPU");
        entityManager = emf.createEntityManager();
    }
    
    
    public static EntityManager getEntityManagerPool(){
        return  Persistence.createEntityManagerFactory("WebDizucarPU").createEntityManager();
    }
    
    
}
